<template>
	<view class="">
		<view class="">
			<view class="top_text">
				用户登录
			</view>
			<!-- #ifdef MP-WEIXIN -->
			<!-- <image class="bg" lazy-load src="@/static/img/loginBg.png" mode=""></image> -->
			<!-- #endif -->
			<view class="logo">
				<image src="@/static/img/dg.png" mode=""></image>
			</view>
		</view>
		<view class="main">
			<!-- <view class="msg">
				请完善信息进行登录
			</view> -->
			<view class="conent">
				<view class="one">
					<view class="in">
						<view class="left">
							手机号
						</view>
						<view class="right">
							<input type="text" value="" placeholder="请输入手机号" v-model="account" />
						</view>
					</view>
				</view>
				<view class="tow">
					
				</view>
				<view class="one">
					<view class="in">
						<view class="left">
							密码
						</view>
						<view class="right">
							<input type="password" value="" placeholder="请输入密码" v-model="password" />
						</view>
					</view>
				</view>
			</view>
			
			<view class="btn" @tap="getLogin">
				确认登录
			</view>
			<!-- #ifdef H5 -->
			<view class="btn" @tap="downLoad">
				下载APP
			</view>
			<!-- #endif -->
			<view class="fn">
				<view class="left">
					还没有账号？<text @tap="routerTo('/pages/login/register')">去注册</text>
				</view>
				<view class="right" @tap="routerTo('/pageB/wpsd')">
					忘记密码
				</view>
			</view>
		</view>
		
		
	</view>
</template>

<script>
	import {
		login,
		user
	} from '@/api/index.js'
	export default{
		data(){
			return{
				account:'',
				password:''
			}
		},
		onLoad() {
			
		},
		methods:{
			downLoad(){
				/*#ifdef H5*/
				window.location.href = 'https://www.yuexiangshidai.cn/yxsd.apk';
				/*#endif*/
			},
			async getLogin(){
				let res = await login({
					account:this.account,
					password:this.password
				})
				console.log(res)
				if(res.code == 1){
					uni.showToast({
						title:'登录成功',
						icon:'none'
					})
					uni.setStorageSync('token',res.data.userinfo.token)
					setTimeout(()=>{
						uni.reLaunch({
							url:'/pages/index/index'
						})
					},1000)
				}else{
					uni.showToast({
						title:res.msg,
						icon:'none'
					})
				}
			},
			routerTo(url){
				uni.navigateTo({
					url:url
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.top_text{
		width: 100%;
		height: 100rpx;
		background-color: #c51114;
		color: #fff;
		text-align: center;
		line-height: 100rpx;
		font-size: 36rpx;
		font-weight: 800;
	}
	.logo{
		display: flex;
		justify-content: center;
		align-items: center;
		margin-bottom: 50rpx;
		image{
			width: 100%;
			height: 400rpx;
		}
	}
	.main{
		position: relative;
		min-height: 100vh;
		// background-image: url(@/static/img/loginBg.png);
		background-size: 100% 100%;
		background-repeat: no-repeat;
		background-position: top left;
		padding: 80rpx 30rpx;
		::v-deep.uni-input-placeholder{
			color: #9c9c9c;
		}
		.conent{
			padding: 20rpx;
			border: 1rpx solid #ccc;
		}
		.bg{
			z-index: -1;
			position: absolute;
			width: 100%;
			height: 100%;
			top: 0;
			left: 0;
		}
		.msg{
			text-align: center;
			color: #fff;
			font-size: 32rpx;
			margin-bottom: 60rpx;
		}
		.one{
			padding: 0 30rpx;
			.in{
				padding: 40rpx 0;
				display: flex;
				justify-content: space-between;
				// border-top: 2rpx solid #9c9c9c;
				.left{
					width: 25%;
					// color: #fff;
				}
				.right{
					width: 75%;
					input{
						color: #9c9c9c;
						text-align: right;
					}
				}
			}
		}
		.tow{
			height: 2rpx;
			background-color: #dcdcdc;
		}
		.btn{
			margin-top: 40rpx;
			margin-bottom: 34rpx;
			width: 100%;
			padding: 30rpx;
			color: #fff;
			text-align: center;
			border-radius: 10rpx;
			// box-shadow: inset 0rpx 8rpx 12rpx 0rpx #ff6347, inset 0rpx -8rpx 20rpx 0rpx #ff6347;
			border: 2rpx solid #ff6347;
			background-color: #ff6347;
		}
		.fn{
			display: flex;
			justify-content: space-between;
			.left{
				color: #9c9c9c;
				font-size: 30rpx;
				text{
					color: #ff6347;
				}
			}
			.right{
				color: #ff6347;
				font-size: 30rpx;
			}
		}
	}
</style>